<template>
  <div class="notice" ref="cover">
    <div class="content">
      <h1 class="title">河北家乡棋牌</h1>
      <div class="certification">
        <div class="info">
          <div>
            <label for="name">真实姓名：</label>
            <input type="text" id="name" placeholder="请输入真实姓名" v-model="name">
          </div>
          <div>
            <label for="number">身份证号：</label>
            <input type="text" id="number" placeholder="请输入身份证号" v-model="number">
          </div>
        </div>
        <agent-button class="certification_btn" :disabled="btnEnable" @btnClick="certificationClick">认证</agent-button>
      </div>
      <button class="disappear" :disabled="knowEnable" @click="knowClick">知道了</button>
    </div>
  </div>
</template>

<script>
import AgentButton from "../../components/common/AgentButton.vue";
import { isIDCard, getUrlString } from "../../scripts/utils.js";
export default {
  data() {
    return {
      name: "",
      number: "",
      knowEnable: false
    };
  },
  props: ["enable"],
  components: {
    AgentButton
  },
  computed: {
    btnEnable() {
      if (this.name && this.number) {
        return false;
      }
      return true;
    }
  },
  created() {
    this.userInfo = this.apiService.getLocalData("userInfo");
  },
  updated() {
    this.knowEnable = !this.enable;
  },
  methods: {
    knowClick() {
      this.$refs.cover.style.display = "none";
    },
    certificationClick() {
      if (this.name.length < 2) {
        return this.$vux.toast.text("请输入真实姓名");
      }
      if (isIDCard(this.number)) {
        this.apiService.user
          .certification({
            realityname: this.name,
            idnumber: this.number,
            agentid: this.userInfo.user_id,
            actiontype: 1
          })
          .then(res => {
            this.$vux.toast.text("感谢您的配合！");
            this.$refs.cover.style.display = "none";
          });
      } else {
        this.$vux.toast.text("身份证号码输入有误");
      }
    }
  }
};
</script>

<style scoped>
.notice {
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.1);
  z-index: 100;
  /* display: none; */
}
.content {
  background-color: #fff;
  width: 90%;
  height: 85%;
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
}
.title {
  background-color: #3cc0ff;
  color: #fff;
  font-size: 0.42rem;
  line-height: 1rem;
  text-align: center;
}
.certification {
  background-color: #fff;
  color: var(--word-color);
  padding: 0.5rem 0 0 0;
}
.certification p {
  text-indent: 2em;
}
.info {
  margin-top: 1rem;
}
.info div {
  margin: 0.2rem 0;
  text-align: center;
}
.info div input {
  border: 1px solid var(--border-color);
  border-radius: 0.1rem;
  padding: 0.1rem 0 0.1rem 0.1rem;
  font-size: 0.3rem;
  width: 4rem;
}
.certification_btn {
  margin-top: 0.5rem;
}
.disappear {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  font-size: 0.36rem;
  text-align: center;
  color: var(--btn-color);
  line-height: 1rem;
  border-top: 0.01rem solid var(--border-color);
}
</style>

